//
//  WYComonTableViewCell.m
//  Withyou
//
//  Created by Tong Lu on 8/1/16.
//  Copyright © 2016 Withyou Inc. All rights reserved.
//

#import "MHCommonTableViewCell.h"

//cell height of 70
static int cellHeight = 15;
static int verticalInset = 10;
static int textLabelHeight = 20;


@implementation MHCommonTableViewCell

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:UITableViewCellStyleDefault reuseIdentifier:reuseIdentifier];
    
    if (self) {
        
        int honrizontalInset = 10;
        int iconImageDimension = cellHeight - verticalInset * 2;
        
        self.descriptionLabel = [[UILabel alloc] initWithFrame:CGRectZero];
        self.descriptionLabel.textAlignment = NSTextAlignmentLeft;
        self.descriptionLabel.numberOfLines = 1;
        self.descriptionLabel.textColor = MHMetionTextColor;
        [self.contentView addSubview:self.descriptionLabel];
        
        self.myImageView = [[UIImageView alloc] initWithFrame:CGRectZero];
        self.myImageView.frame = CGRectMake(honrizontalInset, verticalInset, iconImageDimension, iconImageDimension);
        self.myImageView.layer.cornerRadius = 4;
        self.myImageView.clipsToBounds = YES;
        self.myImageView.contentMode = UIViewContentModeScaleAspectFill;
        
        
        self.rightImageView = [[UIImageView alloc] initWithFrame:CGRectZero];
        self.rightImageView.frame = CGRectMake(MH_SCREEN_WIDTH - 13 - 18 , 22, 18, 16);
        self.rightImageView.image = [UIImage imageNamed:@"icon_cricle_search_choose"];
        self.rightImageView.contentMode = UIViewContentModeScaleAspectFill;
        [self.contentView addSubview:self.rightImageView];
    }
    return self;
}

-(void)setNeedChangeFrame:(BOOL)needChangeFrame
{
    _needChangeFrame = needChangeFrame;
    if (self.needChangeFrame) {
        self.textLabel.y = 22;
    }else
    {
        self.textLabel.y = verticalInset;
    }
}

- (void)layoutSubviews
{
    [super layoutSubviews];
    self.backgroundColor = [UIColor whiteColor];
    
    self.textLabel.font = [UIFont systemFontOfSize:16.0f];
    self.textLabel.textColor = MHTextColor333;
    self.textLabel.frame = CGRectMake(cellHeight, verticalInset, MH_SCREEN_WIDTH - 60 - 70, textLabelHeight);
   
    if (self.needChangeFrame) {
        self.textLabel.y = 22;
    }else
    {
        self.textLabel.y = verticalInset;
    }
    self.descriptionLabel.hidden = self.needChangeFrame;
    self.textLabel.textAlignment = NSTextAlignmentLeft;
    
    self.descriptionLabel.frame = CGRectMake(cellHeight, CGRectGetMaxY(self.textLabel.frame), MH_SCREEN_WIDTH - 60 - 30, textLabelHeight);
    self.descriptionLabel.font = MHRegularFont_12;

    
}


@end




